Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per-service extraEnv supports arbitrary YAML #103

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xrl
Copy link

@xrl xrl commented Sep 25, 2024

I need the ability to map secrets to environment variables. Works towards #102 .

A value file like this:

environment:
  - name: ROOT_ENV_KEY
    value: root1234
searcher:
  extraEnv:
    - name: SEARCHER_ENV_KEY
      value: search123
control_plane:
  extraEnv:
    - name: CONTROL_PLANE_KEY
      value: controlPlane123
indexer:
  extraEnv:
    - name: INDEXER_KEY
      value: indexer123
janitor:
  extraEnv:
    - name: JANITOR_KEY
      value: janitor123
metastore:
  extraEnv:
    - name: METASTORE_KEY
      value: metastore123

yields these kinds of pod definitions:

% helm template meep . -f /tmp/blah.yaml --show-only templates/metastore-deployment.yaml
# snip
          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: QW_CONFIG
              value: /quickwit/node.yaml
            - name: QW_CLUSTER_ID
              value: staging-meep-quickwit
            - name: QW_NODE_ID
              value: "$(POD_NAME)"
            - name: QW_PEER_SEEDS
              value: meep-quickwit-headless
            - name: QW_ADVERTISE_ADDRESS
              value: "$(POD_IP)"
            - name: QW_CLUSTER_ENDPOINT
              value: http://meep-quickwit-metastore.staging.svc.cluster.local:7280
            - name: ROOT_ENV_KEY
              value: root1234
            - name: METASTORE_KEY
              value: metastore123

note: it has the global values from environment but also the service-specific overrides from metastore.extraEnv

and to demonstrate I can do the secret-as-env-value:

janitor:
  extraEnv:
    - name: JANITOR_KEY
      valueFrom:
        secretKeyRef:
          name: some-secret
          key: a-key-in-the-secret

renders out:

          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: QW_CONFIG
              value: /quickwit/node.yaml
            - name: QW_CLUSTER_ID
              value: staging-meep-quickwit
            - name: QW_NODE_ID
              value: "$(POD_NAME)"
            - name: QW_PEER_SEEDS
              value: meep-quickwit-headless
            - name: QW_ADVERTISE_ADDRESS
              value: "$(POD_IP)"
            - name: QW_CLUSTER_ENDPOINT
              value: http://meep-quickwit-metastore.staging.svc.cluster.local:7280
            - name: ROOT_ENV_KEY
              value: root1234
            - name: JANITOR_KEY
              valueFrom:
                secretKeyRef:
                  key: a-key-in-the-secret
                  name: some-secret

@xrl
Copy link
Author

xrl commented Sep 25, 2024

I was able to stand up this branch in my kubernetes cluster with this argo application definition:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: quickwit-tracing
  namespace: argo
spec:
  project: quickwit
  syncPolicy:
    automated:
      prune: true
  source:
    repoURL: "https://github.com/xrl/quickwit-helm-charts.git"
    path: charts/quickwit
    targetRevision: per-service-env-from
    helm:
      releaseName: quickwit-tracing
      values: |
        fullnameOverride: quickwit-tracing
        config:
          storage:
            s3:
              region: eu-central-1
        metastore:
          extraEnv:
           -  name: QW_METASTORE_URI
              valueFrom:
                secretKeyRef:
                  name: quickwittracing-postgres-direct-secret
                  key: POSTGRES_URL
        serviceAccount:
          create: true
          annotations:
            eks.amazonaws.com/role-arn: "arn:aws:iam::SECRET:role/quickwit-tracing"
  destination:
    server: https://kubernetes.default.svc
    namespace: quickwit

@xrl
Copy link
Author

xrl commented Oct 31, 2024

I mention this work from a gist blog post on running Quickwit in an EKS Kube cluster: https://gist.github.com/xrl/43aba28f20fd0efbdf2ea3e58e5c5ded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant